﻿Imports Lourdes.BackEnd.Modelo
Imports Lourdes.BackEnd.BC
Namespace View


  Public Class vProducto

    Private _MercaderiaId As Integer
    Public Property MercaderiaId() As Integer
      Get
        Return _MercaderiaId
      End Get
      Set(ByVal value As Integer)
        _MercaderiaId = value
      End Set
    End Property



    Private _MercaderiaNumero As String
    Public Property MercaderiaNumero() As String
      Get
        Return _MercaderiaNumero
      End Get
      Set(ByVal value As String)
        _MercaderiaNumero = value
      End Set
    End Property


    Private _Nombre As String
    Public Property Nombre() As String
      Get
        Return _Nombre
      End Get
      Set(ByVal value As String)
        _Nombre = value
      End Set
    End Property


    Private _Cantidad As Double
    Public Property Cantidad() As Double
      Get
        Return _Cantidad
      End Get
      Set(ByVal value As Double)
        _Cantidad = value
      End Set
    End Property

    Private _CantidadStock As Double
    Public Property CantidadStock() As Double
      Get
        Return _CantidadStock
      End Get
      Set(ByVal value As Double)
        _CantidadStock = value
      End Set
    End Property


    Private _Precio As Double
    Public Property Precio() As Double
      Get
        Return _Precio
      End Get
      Set(ByVal value As Double)
        _Precio = value
      End Set
    End Property

    Private _Descuentos As Double
    Public Property Descuentos() As Double
      Get
        Return _Descuentos
      End Get
      Set(ByVal value As Double)
        _Descuentos = value
      End Set
    End Property

    Private _Gastos As Double
    Public Property Gastos() As Double
      Get
        Return _Gastos
      End Get
      Set(ByVal value As Double)
        _Gastos = value
      End Set
    End Property

    Private _NrosSerie As List(Of MercaderiaNrosDeSerie)
    Public Property NrosDeSerie() As List(Of MercaderiaNrosDeSerie)
      Get
        Return _NrosSerie
      End Get
      Set(ByVal value As List(Of MercaderiaNrosDeSerie))
        _NrosSerie = value
      End Set
    End Property

    Private _TotalSeleccionado As Double
    Public Property TotalSeleccionado() As Double
      Get
        Return _TotalSeleccionado
      End Get
      Set(ByVal value As Double)
        _TotalSeleccionado = value
      End Set
    End Property


    Public ReadOnly Property TotalLinea() As Double
      Get
        Return ((Me.Cantidad * Me.Precio) - Descuentos + Gastos)
      End Get

    End Property

    Public Shared Function MappToNewvProduct(pProducto As vProducto) As vProducto
      Dim oNuevoProducto As New vProducto
      With pProducto
        oNuevoProducto.MercaderiaId = .MercaderiaId
        oNuevoProducto.MercaderiaNumero = .MercaderiaNumero
        oNuevoProducto.Nombre = .Nombre
        oNuevoProducto.NrosDeSerie = .NrosDeSerie
        oNuevoProducto.Precio = .Precio
        oNuevoProducto.TotalSeleccionado = .TotalSeleccionado
        oNuevoProducto.Cantidad = 1
        oNuevoProducto.Descuentos = .Descuentos
        oNuevoProducto.Gastos = .Gastos
        oNuevoProducto.CantidadStock = .CantidadStock
      End With

      Return oNuevoProducto
    End Function
    Public Sub New()
      Me.Cantidad = 0
      Me.CantidadStock = 0
      Me.Gastos = 0
      Me.MercaderiaId = 0
      Me.MercaderiaNumero = ""
      Me.Nombre = ""
      Me.Precio = 0
      Me.Descuentos = 0
      Me.NrosDeSerie = New List(Of MercaderiaNrosDeSerie)
    End Sub

  End Class

  Public Class vLstProductos
    Inherits List(Of vProducto)

    Public ReadOnly Property Total() As Double
      Get
        Return Me.Sum(Function(o) o.TotalLinea)
      End Get
    End Property

    Public Sub AddNew(ByVal pVProducto As vProducto)
      Me.Add(pVProducto)
    End Sub

  End Class

  
End Namespace